package Admin.servlet;

import Admin.entity.Admin;
import Admin.service.AdminService;
import Admin.service.impl.AdminServiceImpl;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * @author chenle
 * @version 1.0
 * @date 2023/9/25 15:01
 */
@WebServlet("/AdminLikeServlet")
public class AdminLikeServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");

        String name=request.getParameter("name");
        AdminService service=new AdminServiceImpl();
        List<Admin> list=service.getLike(name);

        PrintWriter out=response.getWriter();
        out.print(JSON.toJSONString(list));
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
